package com.zr.dao;

import java.sql.ResultSet;
import com.zr.entity.User;
import com.zr.utils.DBUtils;

public class Dao extends DBUtils{

	public User queryUserById(String uid) throws Exception {
		String sql="select * from user where uid=?";
		Object [] objs= {uid};
		ResultSet rs=query(sql,objs);
		System.out.println(rs);
		if(rs.next()) {
			User u=new User(rs.getString("uid"), rs.getString("pwd"));
			return u;
		}
		return null;
	}

	public int reg(User u) throws Exception {
		String sql="insert into user(uid,pwd,regtime) values(?,?,now())";
		Object[] objs= 
			{u.getUid(),u.getPwd()};
		int result=modify(sql, objs);
		return result;
	}

	public void modifyLastTime(String uid) {
		String sql="update user set lastdate=curdate()  where uid="+uid+"";
		
	}

}
